<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function dequeueFromCircle(pace,length){
            var circle =[]
            for(var i = 0 ;i<length;i++){
                circle.push(i)
            }
            var looper = 0
            var counter = 1
            var temp = []
            while(circle.length!=0){
                if (counter%pace ==0)
                {
                    temp.push(circle.splice(looper,1)[0])
                    looper = looper%circle.length
                }
                else {looper = (looper+1)%circle.length}
                counter++
            }
            return temp
        }
        var temp =dequeueFromCircle(2,5)
    </script>
</body>
</html>